#include "file_reader.h"
#include <iostream>
#include <boost/shared_ptr.hpp>
#include "apriori.h"

using namespace std;
using namespace apriori;
using namespace apriori_test;

int main(int argc, char *argv[])
{
	if(argc < 2) {
		cerr << "Error, usage 'apriori infile'" << endl;
		return 1;
	}
	string file = argv[1];
	file_reader reader(file);
	vector<boost::shared_ptr<dataset> > vec = reader.get_set();
	cout << vec.size() << endl;
	for(int i = 0; i < int(vec.size()); ++i) {
		cout << *vec[i] << endl;
	}

	typedef apriori_alg<dataset, vector> my_apriori;
	typedef my_apriori::t_item t_item;
	typedef list<t_item>::iterator it;

	my_apriori alg(vec, 2, 0.2);
	alg.doit();
	list<t_item> &l = alg.get_result();
	for(it i = l.begin(); i != l.end(); ++i) {
		cout << (*i) << " support: " << i->get_support() << 
		" confidence: " << i->get_confidence() << endl;
	}
	return 0;
}
